<template>
  <footer class="footer">
    <span class="todo-count">剩余<strong>{{noIsDone}}</strong></span>
    <ul class="filters">
      <li>
        <a @click="changeFliter(0)" :class="{selected:filter===0}" href="javascript:;" >全部</a>
      </li>
      <li>
        <a @click="changeFliter(1)" :class="{selected:filter===1}" href="javascript:;">未完成</a>
      </li>
      <li>
        <a @click="changeFliter(2)" :class="{selected:filter===2}" href="javascript:;" >已完成</a>
      </li>
    </ul>
    <button class="clear-completed" @click="clearList" >清除已完成</button>
  </footer>
</template>

<script>
import { mapMutations ,mapState} from 'vuex'
export default {
  methods:{
    ...mapMutations(['setFliter','clearList']),
   changeFliter(i){
    this.setFliter(i)
   }
  },
  computed:{
    ...mapState(['filter','myList']),
    noIsDone(){
      return this.myList.filter(item => item.isDone=== false).length
    }
  }
}
</script>
